package com.pig.graduate.service.impl.event;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.pig.graduate.domain.event.EventExit;
import com.pig.graduate.domain.event.EventTransferDormitory;
import com.pig.graduate.mapper.event.EventTransferDormitoryMapper;
import com.pig.graduate.result.MyResult;
import com.pig.graduate.service.event.EventTransferDormitoryService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
* @author 星星眼
* @description 针对表【event_transfer_dormitory(转舍)】的数据库操作Service实现
* @createDate 2023-03-05 14:49:09
*/
@Service
public class EventTransferDormitoryServiceImpl extends ServiceImpl<EventTransferDormitoryMapper, EventTransferDormitory>
    implements EventTransferDormitoryService{

    @Autowired
    private EventTransferDormitoryMapper eventTransferDormitoryMapper;


    @Override
    public MyResult transferDormitoryList(EventTransferDormitory eventTransferDormitory) {
        PageHelper.startPage(eventTransferDormitory.getPageNum(), eventTransferDormitory.getPageSize());
        List<EventTransferDormitory> list = eventTransferDormitoryMapper.transferDormitoryList(eventTransferDormitory);
        for (EventTransferDormitory transferDormitory : list) {
            String outLocation = transferDormitory.getBuildingsOutName() + "-" + transferDormitory.getColumnOutName();
            transferDormitory.setLocationOut(outLocation);
            String inLocation = transferDormitory.getBuildingsInName() + "-" + transferDormitory.getColumnInName();
            transferDormitory.setLocationIn(inLocation);
        }
        PageInfo<EventTransferDormitory> pageInfo = new PageInfo<>(list);
        return  MyResult.success(pageInfo);
    }
}




